layui.define(['jquery','slick','viewer','rate'],function(exports){
	var modelName = 'articl';
	var  $ = layui.jquery;
	var viewer = layui.viewer;
	var rate = layui.rate;
	var $doc = $(document);
	layui.link('./js/lib/viewer.min.css');
	layui.link('./js/lib/slick.css').link('./js/lib/slick-theme.css');
	$doc.on('click','#nav-btn',function(){
		$("#menus").stop().toggle(300);
		$('body').stop().toggleClass('hide')
	})
	
	// 轮播
	$(".slider-for").slick({
		slidesToShow: 1,
	  slidesToScroll: 1,
	  arrows: false,
	  fade: false,
	  asNavFor: '.slider-nav'
	})
	$('.slider-nav').slick({
	  slidesToShow: 3,
	  slidesToScroll: 1,
	  asNavFor: '.slider-for',
	  dots: false,
	  centerMode: false,
	  focusOnSelect: true,
	  arrows: true,
	  prevArrow:'<div class="arrow arrow-left"><i class="layui-icon layui-icon-left" ></i></div>',
	  nextArrow:'<div class="arrow arrow-right"><i class="layui-icon layui-icon-right" ></i></div>'
	});
	
	// 预览大图
	var viewer = new Viewer(document.getElementById('image-2'), {
		url: 'data-src',
		navbar:false,
		toolbar:false
	});
	var viewer2 = new Viewer(document.getElementById('image'), {
		url: 'data-src',
		navbar:false,
		toolbar:false
	});
	// 选规格
	
	$('.price').text($('.spec-item.active').data('price'));
	$doc.on('click','.spec-item',function(){
		let $this = $(this);
		$this.addClass('active').siblings('.spec-item').removeClass('active')
		var price = $this.data('price');
		$('.price').text(price);
	});
	
	// 评分
	$('.rate').each(function(idx, item) {
		var val = $(item).data('rate');
		rate.render({
			elem: item,
			value: val,
			readonly: true,
			theme: '#de606d'
		})
	});
	
	exports(modelName)
})